<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <style>
        .active {
            color: red;
        }
    </style>
    <div id="app">
        <h2 v-bind:class="{active: isActive, line: isLine}">{{message}}</h2>
        <button v-on:click="clickcc">anniu</button>
        <cnp :ctitle="title"></cnp>
        <cnp :ctitle="title" :cmessage="counter"></cnp>
        <cnp :ctitle="title" :cmessage="counter"></cnp>
    </div>

    <template id="cnp">
        <div>
            <h2>当前计数 {{cmessage}}</h2>
            <!-- <button @cl ick='incr'>+</button>
            <button @click='decr'>-</button> -->
            <ul>
                <li v-for='v in ctitle'>{{v}}</li>
            </ul>
        </div>
    </template>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script>
        // Vue.component('cnp',{
        //     template: '#cnp',
        //     data(){
        //         return {
        //             counter: 0,
        //             title: '123'
        //         }
        //     },
        //     methods:{
        //         decr() {
        //             this.counter--
        //         },
        //         incr() {
        //             this.counter++
        //         }
        //     }
        // });

        const cnp = {
            template: '#cnp',
            // props: ["ctitle","ccounter"],
            props: {
                ctitle: Array,
                cmessage: {
                    type: String,
                    default: 'aaaaaa',
                    required: true
                }
            },
            data() {
                return {
                }
            },
            methods:{
                decr() {
                }
            }

        }
        
        const app = new  Vue({
            el: "#app",
            data: { 
                message : "nihao1",
                isActive: true,
                isLine: true,
                title: ['1111', '222', '333'],
                // counter:''
            },
            methods:  {
                clickcc: function() {
                    this.isActive = ! this.isActive
                }
            }, 
            components: {
                cnp
            }
        })
    </script>
</body>
</html>